package com.autohammal.save.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SerializeUtil {
	
	public static void serializeObject(Object obj,File file) throws FileNotFoundException, IOException{
		if(obj==null||file==null)return;
		ObjectOutputStream oout=new ObjectOutputStream(new FileOutputStream(file));
		oout.writeObject(obj);
		oout.flush();
		oout.close();
	}
	
	public static Object unSerializeObject(File file) throws FileNotFoundException, IOException, ClassNotFoundException{
		if(file==null)return null;
		ObjectInputStream oin=new ObjectInputStream(new FileInputStream(file));
		Object obj=oin.readObject();
		return obj;
	}
	
}
